package clues.bihu.cluesaccident

import android.content.Intent
import android.os.Bundle
import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
import clues.bihu.cluesaccident.jpush.JpushPlugin
import clues.bihu.cluesaccident.jpush.ToastPlugin


class HomeActivity : FlutterActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        GeneratedPluginRegistrant.registerWith(this)
        JpushPlugin.registerWith(this.registrarFor("jpush"))
        ToastPlugin.registerWith(this.registrarFor("toast"))
        getJpushData()
    }


    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        getJpushData()
    }

    private fun getJpushData() {
        if (intent.extras != null) {
            val mClueId = intent.extras.getString("ClueId")
            val mMessageType = intent.extras.getInt("MessageType")
            Preference.saveString("flutter.clueIdJ", "${mClueId}")
            Preference.saveString("flutter.messageTypeJ", "${mMessageType}")
        } else {
            Preference.saveString("flutter.clueIdJ", "")
            Preference.saveString("flutter.messageTypeJ", "")
        }
    }

}
